﻿using Bcmm.Chart.Common;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Bcmm.Chart
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            using TempSQLiteDataBase tempData = new TempSQLiteDataBase();
            tempData.CreateTableByType<MyTestClass>("TESTDATA");

            tempData.AddDataRangeToTable("TESTDATA", new List<MyTestClass>() 
            {
                new MyTestClass(){Max = 100, Min = 0},
                new MyTestClass(){Max = 520, Min=250}
            });

            tempData.DeleteDataFromTable("TESTDATA", 1);


            //using SQLiteHelper sqliteHelper = new SQLiteHelper();

            //var tempConnection = sqliteHelper.CreateTempLocalConnection();
            //tempConnection.Open();
            //using var command = tempConnection.CreateCommand();

            //command.CommandText = "CREATE TABLE TEMPTABLE (FirtColumn double, SecondColumn double);";
            //command.ExecuteNonQuery();

            //command.CommandText = "INSERT INTO TEMPTABLE VALUES (100, 100);";
            //command.ExecuteNonQuery();

            //command.CommandText = "SELECT * FROM TEMPTABLE;";
            //var reader = command.ExecuteReader();

            //if (reader.HasRows)
            //{
            //    while (reader.Read())
            //    {
            //        double column1 = reader.GetDouble(1);
            //    }
            //}

            //reader.Close();
            //tempConnection.Close(); ;
        }

        protected override void OnRender(DrawingContext drawingContext)
        {
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();

            // 收集绘制指令。
            for (int i = 0; i < 100000; i++)
            {
                drawingContext.DrawLine(new Pen() { Brush = Brushes.Red, Thickness = 2 }, new Point(0, 0), new Point(200, 200));
            }

            stopwatch.Stop();
            var time = stopwatch.ElapsedMilliseconds.ToString();
        }
    }
}
